import request from '@/utils/request'
import upload from '@/utils/upload'
// 查询维保任务列表
export function listTask(query) {
  return request({
    url: '/mk/task/list',
    method: 'get',
    params: query
  })
}

// 根据报修人id和维修状态来查询维保任务列表
export function queryStateToList(query) {
  return request({
    url: '/mk/task/queryStateToList',
    method: 'get',
    params: query
  })
}
// 查询维保任务详细
export function getTask(maintenanceCode) {
  return request({
    url: '/mk/task/' + maintenanceCode,
    method: 'get'
  })
}

// 新增维保任务
export function addTask(data) {
  return request({
    url: '/mk/task',
    method: 'post',
    data: data
  })
}

// 修改维保任务
export function updateTask(data) {
  return request({
    url: '/mk/task',
    method: 'put',
    data: data
  })
}
// 删除维保任务
export function delTask(maintenanceCode) {
  return request({
    url: '/mk/task/delTaskBycode/' + maintenanceCode,
    method: 'delete'
  })
}
// 评价图片上传
export function uploadEvaluateImg(data) {
  return upload({
    url: '/mk/evaluateImg/imgUpload/' + data.maintenanceCode,
    name: data.name,
    filePath: data.filePath
  })
}

// 报修图片上传新增
export function uploadMaintenanceImgAdd(data) {
  return upload({
    url: '/mk/maintenanceImg/maintenanceImgUploadAdd/' + data.equipmentCode,
    name: data.name,
    filePath: data.filePath
  })
}
// 报修视频上传新增
export function uploadMaintenanceVideoAdd(data) {
  return upload({
    url: '/mk/maintenanceImg/maintenanceVideoUploadAdd/' + data.equipmentCode,
    name: data.name,
    filePath: data.filePath
  })
}


// 删除维保任务
export function delImgByEquipmentCode(equipmentCode) {
  return request({
    url: '/mk/maintenanceImg/deleteMkMaintenanceImgByEquipmentCode/' + equipmentCode,
    method: 'delete'
  })
}
// 查询该报单的所有图片
export function querymaintenceImgList(query) {
  return request({
    url: '/mk/maintenanceImg/list',
    method: 'get',
    params: query
  })
}
// 查询该报单的所有视频
export function querymaintenceVideoList(query) {
  return request({
    url: '/mk/maintenanceImg/videoList',
    method: 'get',
    params: query
  })
}


// 查询该维修完成后上传的图片
export function queryRepairImgList(query) {
  return request({
    url: '/mk/repairImg/list',
    method: 'get',
    params: query
  })
}

// 查询该评价的所有图片
export function queryEvaluateImgList(query) {
  return request({
    url: '/mk/evaluateImg/list',
    method: 'get',
    params: query
  })
}
// 查询该报单的所有图片
export function delImgbyId(id) {
  return request({
    url: '/mk/maintenanceImg/deleteImgById/'+id,
    method: 'delete'
  })
}

// 查询维保的数量根据状态  
export function selectCountByStatus(query) {
  return request({
    url: '/mk/task/selectCountByStatus',
    method: 'get',
    params: query
  }) 
}

//查询所有的维修人员根据接单数来排序
export function selectAllMaintenanId(query) {
  return request({
    url: '/mk/task/selectAllMaintenanId',
    method: 'get',
    params:query
  }) 
}

//根据报修单查询状态流程
export function selectAllByMaintenanCode(query) {
  return request({
    url: '/mk/maintenancestate/list',
    method: 'get',
    params:query
  }) 
}

// 根据报修现在状态新增流程
export function addTaskState(data) {
  return request({
    url: '/mk/maintenancestate',
    method: 'post',
    data: data
  })
}


// 根据报修现在状态新增多条流程
export function addMkMaintenanceList(data) {
  return request({
    url: '/mk/maintenancestate/addMkMaintenanceList',
    method: 'post',
    data: data
  })
}
// 根据报修设备id查询报修单多少
export function selectCountByEquipmentCode(equipmentNo) {
  return request({
    url: '/mk/task/selectCountByEquipmentCode/'+equipmentNo,
    method: 'get'
  })
}

// 根据设备id删除报修单
export function deleteTaskByEquimentNo(equipmentNo) {
  return request({
    url: '/mk/task/deleteTaskByEquimentNo/'+equipmentNo,
    method: 'delete'
  })
}

// 根据报修人和报修时间查询报表
export function queryUserReportForms(query) {
  return request({
    url: '/mk/task/queryUserReportForms',
    method: 'get',
    params: query
  }) 
}

// 订阅维修通知消息方法
export function sendMessage(data) {
  return request({
    url: '/mk/task/sendMessage',
    method: 'post',
    data: data
  })
}
//订阅维修进度消息方法
export function sendScheduleMessage(data) {
  return request({
    url: '/mk/task/sendScheduleMessage',
    method: 'post',
    data: data
  })
}

// 维修完成图片上传新增
export function uploadRepairImgAdd(data) {
  return upload({
    url: '/mk/repairImg/uploadRepairImgAdd/' + data.repairImgCode,
    name: data.name,
    filePath: data.filePath
  })
}
// 删除维修完成图片
export function delRepairImgByCode(repairImgCode) {
  return request({
    url: '/mk/repairImg/deleteRepairImgBycode/' + repairImgCode,
    method: 'delete'
  })
}
// 根据编码查询完成图片
export function queryByrepairImgCodelist(repairImgCode) {
  return request({
    url: '/mk/repairImg/queryByrepairImgCodelist/'+repairImgCode,
    method: 'get'
  })
}
// // 新增维保任务
// export function addDistributionRecord(data) {
//   return request({
//     url: '/mk/record',
//     method: 'post',
//     data: data
//   })
// }
